﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Mesuro.Equation.Libraries {
	public static class ComplexNumbers {
		private static EqSymbolInstance _complexConstant;
		public static EqSymbolInstance ComplexConstant { get { return _complexConstant; } }
		public static void Load( string complexConstant = "i", EqScope inScope = null ) {
			if (inScope == null)
				inScope = EqScope.Intrinsic;
			inScope.CreateSymbol( complexConstant, EqSymbolFlags.WriteProtect | EqSymbolFlags.Permanent );
			_complexConstant = new EqSymbolInstance( complexConstant );
			EqOperatorDefinition.Register( "*", EqOperatorDefinition.PRECEDENCE_MULTIPLICATIVE, EqOperatorArguments.BINARY, delegate( EqScope scope, EqTerm LHS, EqTerm RHS, EqOperatorDefinition definition ) {
				if (ComplexConstant.Equals( LHS ) && ComplexConstant.Equals( RHS ))
					return new EqRealConstant( -1 );
				return null;
			} );
		}
	}
}
